package com.roy.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.File;

@SpringBootApplication
@Configuration
public class JettyJspApplication {

	public static void main(String[] args) {
		SpringApplication.run(JettyJspApplication.class, args);
	}

	/**
	 * 如果是jsp的web项目一定要设定这个Bean，否则找不到jsp文件
	 * @return
	 */
	@Bean
	public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
		ConfigurableEmbeddedServletContainer factory = new JettyEmbeddedServletContainerFactory();
		factory.setDocumentRoot(new File("D:\\program\\codelib\\spring-learn-parent\\jetty-jsp\\src\\main\\webapp\\"));
		return (EmbeddedServletContainerFactory) factory;
	}
}
